package com.syqc.monitor.ui.cost

import com.syqc.comlib.utils.GsonUtil
import com.syqc.entity.YearVrfInfoFee
import com.syqc.monitor.R
import com.syqc.utils.TimeUtil


class CarYearViewModel : BaseFeeViewModel() {

    var feeYear = ""
    private var yearFeeEntity: String = ""
    private var yearFee: String = ""

    //加油日期
    var update = TimeUtil.instance.getNowTime(true)

    override fun isParamsOk(): Boolean {
        if (carId.isEmpty()) {
            toast(R.string.hint_toast_choose_car)
            return false
        }
        if (feeYear.isEmpty()) {
            toast(R.string.hint_toast_fee)
            return false
        }

        val entity = YearVrfInfoFee(
            carId, update, remark, feeYear
        )

        yearFee = GsonUtil.toJson(entity)
        if ("$yearFee$photos" == yearFeeEntity && isSuccess) {
            toast(R.string.toast_repeat_same_data)
            return false
        }
        yearFeeEntity = "$yearFee$photos"
        return true
    }

    fun uploadCarYear() {
        if (!isParamsOk()) return
        uploadFee("FeeYearVrf", yearFee.replace("%", "%25"))
    }
}